<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>活动列表</title>

    <%include ../../common.ejs%>

    <script type="text/javascript" src="/javascripts/sweet-alert.js"></script>
    <link rel="stylesheet" type="text/css" href="/stylesheets/sweet-alert.css">
    <style>
        ._label-color{
            color:white; text-decoration:none;font-weight:bold;}
        .table-div .caption {
            font-size: 30px;

        }
        .input-costom{

            width: 130px;
        }
    </style>

    <script type="text/javascript">



        $(document).ready(function() {
            if($("#pagination")){
               //var pagecount = <%= locals.pagecount %>;
               // var pagesize = <%= locals.pagesize %>;
              //  var currentpage = <%= locals.currentpage %>;
                var pagecount=<%=actives.length%>;
                var pagesize=1;
                var currentpage=<%=pages%>;
                var counts,pagehtml="";
                if(pagecount%pagesize==0){
                    counts = parseInt(pagecount/pagesize);
                }else{
                    counts = parseInt(pagecount/pagesize)+1;
                }
                //只有一页内容
                if(pagecount<=pagesize){pagehtml="";}
                //大于一页内容
                if(pagecount>pagesize){
                    if(currentpage>1){
                        pagehtml+= '<li><a href="/admin/activityManage/activityList?page='+(currentpage-1)+'">上一页</a></li>';
                    }
                    for(var i=0;i<counts-2;i++){
                        if(i>=(currentpage-3) && i<(currentpage+3)){
                            if(i==currentpage-1){
                                pagehtml+= '<li class="active"><a href="/admin/activityManage/activityList?page='+(i+1)+'">'+(i+1)+'</a></li>';
                            }else{
                                pagehtml+= '<li><a href="/admin/activityManage/activityList?page='+(i+1)+'">'+(i+1)+'</a></li>';
                            }

                        }
                    }
                    if(currentpage<counts){
                        pagehtml+= '<li><a href="/admin/activityManage/activityList?page='+(currentpage+1)+'">下一页</a></li>';
                    }
                }
                $("#pagination").html(pagehtml);
            }
        });
        function confirms(id){
            swal({
                        title: "是否删除该活动？",
                        test:"test",
                        type: "warning",
                        showCancelButton: true,
                        confirmButtonColor: '#DD6B55',
                        confirmButtonText: '删除',
                        cancelButtonText: "保留",
                        closeOnConfirm: false,
                        closeOnCancel: true
                    },

                    function(isConfirm){
                        var activityId=id;
                        if (isConfirm){
                            swal("Deleted!", "Your imaginary file has been deleted.", "success");
                                window.location.href="delActivityList?id="+activityId;

                        }
                    });
        };
    </script>
</head>
<body>
<div id="top">
    <% include ../top.ejs%>
</div>
<div class="container-fluid" style="margin-top: 20px;">
    <div class="row">
        <div class="col-md-1">
        </div>
        <div id="left" class="col-md-2">
            <% include ../left.ejs%>
        </div>
        <div class="col-md-8 bodyDiv" id="right">

            <div class="table-div">
                <span class="caption" >活动列表</span>
                <div class="row">
                    <form class="form-horizontal" role="form" method="get">
                        <div class="col-md-6"></div>
                        <div class="col-md-2">

                            <select class="form-control">
                                <option value="活动主题">活动主题</option>
                            </select>

                        </div>

                        <div class="col-md-2  input-costom " >
                            <input type="text" name="subject" value="<%= param %>" class="form-control">
                        </div>
                        <div class="col-md-2">
                            <button type="submit" class="btn btn-default">搜索</button>
                        </div>
                    </form>
                </div>
                <table class="table table-striped">

                    <thead>
                    <tr>
                        <th>活动主题</th>
                        <th>开始时间</th>
                        <th>限制人数</th>
                        <th>活动地点</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <% if(actives.length>0){%>
                        <% for(var i=0; i<actives.length; i++) { %>
                        <tr>
                            <td><a href="toActivityDetail?id=<%= actives[i].id %>"><%= actives[i].subject %></a></td>
                            <td><%= actives[i].startTime %></td>
                            <td><%= actives[i].number %></td>
                            <td><%= actives[i].location %></td>

                            <td><a href="toActivityDetail?id=<%= actives[i].id %>">修改</a>&nbsp;<a href="#"  onclick="confirms(<%= actives[i].activeDetailId %>)">删除
                               <%if(actives[i].status==1){%>
                                &nbsp;<a href="toInvite?id=<%= actives[i].id %>">邀请</a></td>
                                <%}%>

                        </tr>
                        <% } %>
                    <% }else {%>
                    <tr><td colspan="5" class="text-center"><h1>抱歉 没有数据</h1></td></tr>
                    <% } %>

                    </tbody>

                </table>

            </div>
            <div class="row">
                <div class="col-md-4"></div>
                <div class="col-md-6">
                    <ul class="pagination" id="pagination">
                    <!--    <li><a href="#">&laquo;</a></li>
                        <li><a href="#">1</a></li>
                        <li><a href="#">2</a></li>
                        <li><a href="#">3</a></li>
                        <li><a href="#">4</a></li>
                        <li><a href="#">5</a></li>
                        <li><a href="#">&raquo;</a></li>  -->
                    </ul>
                </div>

            </div>

        </div>

    </div>
</div>
</div>
<div id="bottom"></div>
</body>
</html>